import {REGISTER, REGISTER_SUBMIT} from "./const";
import {setAuthority} from "../../utils/authority";

const initState = {
  status: undefined,
};

const reducer = (state = initState, {type, payload}) => {
  switch (type) {
    case REGISTER:
      payload.currentAuthority = payload.currentAuthority || 'admin';
      setAuthority(payload.currentAuthority);
      return {...state, ...payload};
    default:
      return state;
  }
};

export default reducer;
